<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>基于Bootstrap4的Toast提示插件</title>
	<link rel="stylesheet" href="https://www.jq22.com/jquery/bootstrap-4.2.1.css">
    <link rel="stylesheet" href="vendor/toast/toast.css ">
	<style>
		.header{text-align: center;line-height: 30px}
		.demo{
	width: 900px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 100px;
		}
		.demo a{
	padding-left: 10px;
	padding-right: 10px;
	line-height: 30px;
	border: 1px solid #3A3A3A;
	display: inline-block;
	margin-left: 10px;
	margin-right: 10px;
	text-decoration: none;
}.demo a:hover{
	background-color:#BDF7F8;
}
	</style>
</head>
<body>

		<header class="header">
			<h1>基于Bootstrap4的Toast提示插件</h1>
			<p>A Bootstrap 4.2+ jQuery plugin for the toast component</p>
		</header>

			<div class="demo">
				<a href="javascript:show_random_toast();">显示随机Toast</a>
				<a href="javascript:show_random_toast(true);">悬停时暂停</a>
				<a href="javascript:show_image_toast();">显示图像 Toast</a>
				<a href="javascript:show_random_snack();">显示随机Snack</a>
				<a href="javascript:show_toast_in_container();">在容器中显示Toast</a>
			</div>

		

	
	<script src="vendor/jquery/jquery.min.js" type="text/javascript"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="https://www.jq22.com/jquery/bootstrap-4.2.1.js"></script>
    <script src="vendor/toast/toast.js"></script>
    <script>
            $('body').tooltip({
                selector: '[data-toggle="tooltip"]'
            });

            var TYPES = ['info', 'warning', 'success', 'error'],
                TITLES = {
                    'info': 'Notice!',
                    'success': 'Awesome!',
                    'warning': 'Watch Out!',
                    'error': 'Doh!'
                },
                CONTENT = {
                    'info': 'Hello, world! This is a toast message.',
                    'success': 'The action has been completed.',
                    'warning': 'It\'s all about to go wrong',
                    'error': 'It all went wrong.'
                };

            function show_random_toast(pause_on_hover = false) {
                var type = TYPES[Math.floor(Math.random() * TYPES.length)],
                    title = TITLES[type],
                    content = CONTENT[type];

                $.toast({
                    title: title,
                    subtitle: '11 mins ago',
                    content: content,
                    type: type,
                    pause_on_hover: pause_on_hover,
                    delay: 5000
                });
            }

            function show_image_toast() {
                var type = TYPES[1],
                    title = TITLES[1],
                    content = CONTENT[1];


            }

            function show_random_snack() {
                var type = TYPES[Math.floor(Math.random() * TYPES.length)],
                    content = CONTENT[type].replace('toast', 'snack');

                $.toast({
                    title: content,
                    type: type,
                    delay: 5000
                });
            }

            function show_toast_in_container() {
                var type = TYPES[Math.floor(Math.random() * TYPES.length)],
                    title = TITLES[type],
                    content = CONTENT[type];

                $.toast({
                    title: title,
                    subtitle: '11 mins ago',
                    content: content,
                    type: type,
                    delay: 5000,
                    container: $("#my_container")
                });
            }
        </script>
</body>
</html>